from django.db import models
from django.contrib.auth.models import AbstractUser
from system.models import Department
from students.models import Class
#角色



class Role(models.Model):
    role_name=models.CharField(max_length=10,verbose_name='角色、职位')
    department=models.ForeignKey(to=Department,on_delete=models.CASCADE,verbose_name='部门id')
    level=models.IntegerField(verbose_name='岗位级别')
    duty = models.IntegerField(verbose_name='岗位职责',null=True,blank=True)
    class Meta:
        db_table='role'
        ordering=('-id',)
#员工模型
class AdminUser(AbstractUser):
    phone=models.CharField(max_length=11,verbose_name='手机号',unique=True)
    name = models.CharField(max_length=10)#员工的姓名
    role=models.ManyToManyField(to=Role)
    def __str__(self):
        return self.name
    class Meta:
        db_table='adminuser'
        ordering=('-id',)




class UserAppraisal(models.Model):
    user_id = models.ForeignKey(to=AdminUser,on_delete=models.SET_NULL,verbose_name='教职工id',null=True)
    answer = models.TextField(max_length=200,verbose_name='答案')
    cls=models.ForeignKey(to=Class,on_delete=models.SET_NULL,null=True)


class AppraisalQuestionBank(models.Model):
    title = models.TextField(max_length=200,verbose_name='题干')
    a = models.TextField(max_length=200,verbose_name='选项a',null=True)
    b = models.TextField(max_length=200,verbose_name='选项b',null=True)
    c = models.TextField(max_length=200,verbose_name='选项c',null=True)
    d = models.TextField(max_length=200,verbose_name='选项d',null=True)
    e = models.TextField(max_length=200,verbose_name='选项e',null=True)
    f = models.TextField(max_length=200,verbose_name='选项f',null=True)
    answer = models.CharField(max_length=10,verbose_name='最佳答案')
    topictype = models.TextField(max_length=200,verbose_name='试题类型') #选择题or简答题
    classify = models.TextField(max_length=200,verbose_name='试题分类')  #该题是 讲师or导员 的


